package com.cx.meta.enums;

/**
 * @author flysand
 * @package com.cx.meta.enums
 * @date 2021-11-07 18:12
 * @des ErrorCode :
 */
public enum ErrCode {
    //成功
    SUCCESS(0, "SUCCESS"),

    //数据错误
    DATA_ERROR(100, "数据错误"),

    // 错误信息
    USERNAME_OR_PASSWORD_ERROR(101, "用户名或密码错误"),

    // 验证码
    CODE_SUCCESS(200, "验证码正确"),
    CODE_EXPIRED(201, "验证码已过期"),
    CODE_ERROR(202, "验证码不正确"),

    MOBILE_FREEZE(211, "手机号已冻结，请24小时后再试"),


    ;


    private int code;
    private String msg;

    public static ErrCode getErrCodeByCode(int code) {
        for (ErrCode errCode : ErrCode.values()) {
            if (errCode.getCode() == code) {
                return errCode;
            }
        }
        return DATA_ERROR;
    }

    private ErrCode() {

    }

    ErrCode(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
